# to attach leaflet dependencies we do an invisible map
# otherwise procedural leaflets wont render
# https://stackoverflow.com/questions/63534247/recommended-way-to-initialize-js-renderer-in-asis-r-markdown-chunk
leaflet::leaflet(width = 0, height = 0)
sli_performance%>%
select(-raw_comparison) %>%
DT::datatable()
for (i in 1:nrow(sli_performance)){
cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
print(plot_sli_performance(sli_performance$raw_comparison[[i]],
title = sprintf("%s: Absolute performance", sli_performance$method[[i]]),
plot_type = "absolute"))
}
for (i in 1:nrow(sli_performance)){
cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
map <- leaflet_sli_performance(sli_performance$raw_comparison[[i]], ons_shp, "diff_count")
cat(as.character(htmltools::tagList(map)))
}
for (i in 1:nrow(sli_performance)){
cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
print(plot_sli_performance(sli_performance$raw_comparison[[i]],
title = sprintf("%s: Relative performance", sli_performance$method[[i]]),
plot_type = "proportional"))
print("\n\n")
print(sli_performance$raw_comparison[[i]]$diff_prop %>%
abs() %>%
hist(main = paste0("Histogram of mean abs. pct. error, ", sli_performance$method[[i]])))
print("\n\n")
print(sli_performance$raw_comparison[[i]]$diff_prop %>%
abs() %>%
summary())
}
[1]
“”
$breaks
[1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50
$counts [1] 85 7 3 5 3 2 1 0 1 1
$density [1] 15.7407407 1.2962963 0.5555556 0.9259259 0.5555556 0.3703704 [7] 0.1851852 0.0000000 0.1851852 0.1851852
$mids [1] 0.025 0.075 0.125 0.175 0.225 0.275 0.325 0.375 0.425 0.475
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.0000221 0.0022596 0.0090042 0.0472590 0.0351333 0.4603428
[1]
“”
$breaks
[1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
$counts [1] 83 11 5 4 2 0 1 1 0 1
$density [1] 7.68518519 1.01851852 0.46296296 0.37037037 0.18518519 0.00000000 [7] 0.09259259 0.09259259 0.00000000 0.09259259
$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002648 0.014955 0.083289 0.080902 1.000000
## Warning: Removed 1 rows containing missing values (geom_point).
[1]
“”
$breaks
[1] 0.0 0.2 0.4 0.6 0.8 1.0 1.2
$counts [1] 104 1 1 0 1 1
$density [1] 4.8148148 0.0462963 0.0462963 0.0000000 0.0462963 0.0462963
$mids [1] 0.1 0.3 0.5 0.7 0.9 1.1
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002538 0.012595 0.054304 0.041060 1.171429
[1]
“”
$breaks
[1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
$counts [1] 96 8 1 1 1 0 0 0 1
$density [1] 8.88888889 0.74074074 0.09259259 0.09259259 0.09259259 0.00000000 0.00000000 [8] 0.00000000 0.09259259
$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002797 0.012908 0.046821 0.048937 0.882353
[1]
“”
$breaks
[1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
$counts [1] 95 9 1 0 1 0 1 0 1
$density [1] 8.79629630 0.83333333 0.09259259 0.00000000 0.09259259 0.00000000 0.09259259 [8] 0.00000000 0.09259259
$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85
$xname [1] “.”
$equidist [1] TRUE
attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002538 0.011900 0.047541 0.034546 0.882353
for (i in 1:nrow(sli_performance)){
cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
map <- leaflet_sli_performance(sli_performance$raw_comparison[[i]], ons_shp, "diff_prop")
cat(as.character(htmltools::tagList(map)))
}